<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .boss {
            width: 300px;
            height: 330px;
            border: 1px solid greenyellow;
        }

        .imgs {
            width: 300px;
            height: 300px;
            background-color: pink;
        }

        .imgs img {
            width: 100%;
            height: 100%;
        }

        .ps {
            width: 100px;
            height: 30px;
            background-color: skyblue;
            margin: 0 auto;
        }

        .uli li {
            width: 20px;
            height: 20px;
            display: inline-block;
            border-radius: 100%;
            background: pink;
        }

        .col {
            background-color: green !important;
        }
    </style>
</head>

<body>
    <div class="boss">
        <div class="imgs">
            <img src="../DOM/img/slider01.jpg" alt="">
        </div>
        <div class="ps">
            <ul class="uli">
                <li class="col"></li>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </div>
    </div>
    <script>
        // 5.li的颜色通过变量来改变 classList()
        // 1.获取图片,li对象
        let imgs = document.querySelector('.imgs img').src;
        let lis = document.querySelectorAll('li');
        // 2.设置一个变量
        let num = 0;
        // 3.设置定时器
        setInterval(function () {
            // 给小圆点清除样式
            lis[num].classList.remove('col');//012
            num++;//12\
            imgs = `../DOM/img/slider0${num}.jpg`;//123

            if (num === 3) {
                num = 0;
            }
            // 给小圆点添加样式
            lis[num].classList.add('col');//123
            // 切换图片

        }, 900)
    </script>
</body>

</html>